#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 n,ans;
int main()
{
    cin >> n;
    string s;
    cin >> s;
    vector<int> a;
    for (int i = 0;i < n;i++) {
        if (s[i] == 'e') {
            a.push_back(i);
        }
        else if (s[i] == 'f') {
            for (auto t : a) {
                ans += i - t;
            }
        }
    }
    cout << ans << endl;
}